part of '../repository.dart';

const _kPurchasedSubscriptionInfoPauseAutoResumeTimeKey = 'auto_resume_time';

class _PurchasedSubscriptionInfoPauseInfoDto extends Equatable {
  const _PurchasedSubscriptionInfoPauseInfoDto._internal({
    required this.autoResumeTimeDto,
  });

  final _TimeDto autoResumeTimeDto;

  @override
  List<Object?> get props {
    return [
      autoResumeTimeDto,
    ];
  }

  factory _PurchasedSubscriptionInfoPauseInfoDto.fromJson(Map<String, dynamic> json) {
    final autoResumeTimeString = json[_kPurchasedSubscriptionInfoPauseAutoResumeTimeKey] as String;
    final autoResumeTimeDto = _TimeDto.fromString(autoResumeTimeString);

    return _PurchasedSubscriptionInfoPauseInfoDto._internal(
      autoResumeTimeDto: autoResumeTimeDto,
    );
  }

  factory _PurchasedSubscriptionInfoPauseInfoDto.fromEntity(
      GooglePlayPurchasedSubscriptionInfoPauseInfo pauseInfo) {
    final autoResumeTimeDto = _TimeDto.fromEntity(pauseInfo.autoResumeTime);

    return _PurchasedSubscriptionInfoPauseInfoDto._internal(
      autoResumeTimeDto: autoResumeTimeDto,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kPurchasedSubscriptionInfoPauseAutoResumeTimeKey: autoResumeTimeDto.toString(),
    };
  }

  GooglePlayPurchasedSubscriptionInfoPauseInfo toEntity() {
    return GooglePlayPurchasedSubscriptionInfoPauseInfo(
      autoResumeTime: autoResumeTimeDto.toEntity(),
    );
  }
}
